package com.wnhz.work.yz.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.wnhz.work.yz.R;
import com.wnhz.work.yz.bean.BathItemBean;

import java.util.List;

/**
 * Created by admin on 2017/1/14.
 */
public class ParamItemAdapter extends BaseAdapter {
    private Context context;
    private List<BathItemBean> dataList;

    public ParamItemAdapter(Context context, List<BathItemBean> dataList) {
        this.context = context;
        this.dataList = dataList;
    }

    @Override
    public int getCount() {
        return dataList.size();
    }

    @Override
    public Object getItem(int position) {
        return dataList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ParamItemViewHolder viewHolder = null;
        if (convertView == null) {
            viewHolder = new ParamItemViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.bath_param_item, null);
            viewHolder.tv_name = (TextView) convertView.findViewById(R.id.tv_name);
            viewHolder.tv_number = (TextView) convertView.findViewById(R.id.tv_number);
            viewHolder.tv_content = (TextView) convertView.findViewById(R.id.tv_content);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ParamItemViewHolder) convertView.getTag();
        }

        viewHolder.tv_name.setText(dataList.get(position).getGoods_name());
        viewHolder.tv_number.setText("×" + dataList.get(position).getGoods_nums());
        viewHolder.tv_content.setText(dataList.get(position).getSku_info());

        return convertView;
    }

    class ParamItemViewHolder {
        TextView tv_name;
        TextView tv_number;
        TextView tv_content;
    }
}
